package gamebackend;

import generators.BasicBlockGenerator;
import generators.BlockRule;
import generators.EmbiggenGenerator;
import generators.HorizontalStreakGenerator;
import generators.ScaredGenerator;
import generators.SquareGenerator;
import generators.VerticalStreakGenerator;
import gui.BlockStyle;

import framework.Color;
import java.util.Random;

public class AsteroidBiome extends GameSession.Biome {

	public AsteroidBiome(GameSession the_session,
			final int the_tier, Random the_random, double the_length) {
		the_session.super(the_session, the_tier, the_random, the_length);
		
		addEasyPath(new FlightPath(Block.PRIMARY_PATH, getEasyPath(), 40), getLength());
		addHardPath(new FlightPath(Block.SECONDARY_PATH, getHardPath(), 16), getLength());
		MultiFlier multi = new MultiFlier();
		multi.add(new EasyFlier(getEasyPath().getShipFlier(), getRandom(), 15, getWidth() - 15));
		multi.add(new EasyFlier(getHardPath().getShipFlier(), getRandom(), 8, getGameSession().getWidth() - 8));
		final int extras = 5;
		for (int i = 1; i < extras; i++) {
			final FlightPath added = new FlightPath(Block.SECONDARY_PATH, getHardPath(), 30 / i);
			multi.add(new EasyFlier(added.getShipFlier(), getRandom(), 30 / i / 2, getGameSession().getWidth() - 30 / i / 2));
			// TODO these extra fliers don't expire exactly when their paths do.
			addFlightPath(added, getLength() * i * 2 / extras / 3);
		}
		setFlier(multi);
		//addGenerator(new BasicBlockGenerator(new Block(BlockStyle.PLAIN, Color.BLUE), BlockRule.EMPTY, getRandom(), 1), getLength());
		final Block red = new Block(BlockStyle.ASTEROID, new Color(130, 70, 70));
		addGenerator(new ScaredGenerator(red, getRandom(), 1, 1 - 3.1 / 16, ScaredGenerator.BRASH), getLength());
		//addGenerator(new BasicBlockGenerator(red, BlockRule.EMPTY, getRandom(), .2), getLength());
		final Block orange = new Block(BlockStyle.ASTEROID, new Color(230, 180, 70));
		addGenerator(new SquareGenerator(orange, getRandom(), .02), getLength());
		addGenerator(new ScaredGenerator(orange, getRandom(), 0, .3 / 16, ScaredGenerator.SHY), getLength());
		addGenerator(new EmbiggenGenerator(red, BlockRule.EMPTY), getLength());
		addGenerator(new HorizontalStreakGenerator(red, getRandom(), .3, HorizontalStreakGenerator.BOTH), getLength());
		
		addGenerator(new HorizontalStreakGenerator(orange, getRandom(), .2, HorizontalStreakGenerator.BOTH), getLength());
		addGenerator(new VerticalStreakGenerator(orange, getRandom(), .15), getLength());
		
		addGenerator(new BasicBlockGenerator(Block.EMPTY_BLOCK, new BlockRule(){

			@Override
			public boolean test(Block the_block) {
				return the_block == red || the_block == orange;
			}}, getRandom(), .2), getLength());
	}
	@Override
	public void step(double y_change) {
		super.step(y_change);
	}

}
